function KeyManager(){}

KeyManager.prototype = {
    initialize: function(document)
    {
        var that = this;
        that.keyPressed = {};
        document.onkeydown = function(event){
            that.keyPressed[event.keyCode] = true;
            if (that.downCallback){
                that.downCallback(event.keyCode);
            }
        }
        document.onkeyup = function(event){
            that.keyPressed[event.keyCode] = false;
        }
    },
    setDownCallback: function(callback)
    {
        this.downCallback = callback;
    },
    setIntervalCallback: function(callback, time_ms)
    {
        this.intervalCallback = callback;
        setInterval(this.intervalCallback, time_ms);
    }

};

KeyManager.create = function(){
    var key = new KeyManager();
    return key;
}

